#!/bin/bash

START_PROFILE=3
if [ $# -eq 1 ]; then
  START_PROFILE=$1
fi
if [ -z "`echo "$START_PROFILE" | grep -E '^[1-3]+$'`" ]; then
  echo "illegal profile：$START_PROFILE"
  exit 9
fi

if [ $(($START_PROFILE&1)) -eq 1 ]; then
  echo 'staring mysql ...'
  /usr/sys/soft/exec/mysql5.7/bin/mysqld_safe --defaults-file=/usr/sys/soft/exec/my.cnf --datadir=/usr/sys/data/mysql5.7 --socket=/usr/sys/data/mysql5.7/mysql.sock --pid-file=/usr/sys/data/mysql5.7/run/mysqld.pid &
fi

if [ $(($START_PROFILE&2)) -eq 2 ]; then
  echo 'starting redis ...'
  /usr/sys/soft/exec/redis/bin/redis-server /usr/sys/soft/exec/redis/redis.conf &
fi

echo 'done'
